import createBlobFromDataUri from '../../src/helpers/create-blob-from-data-uri';

// 100 x 100 (1041 bytes)
const png = '';

// 128 x 68
const pngFried = '';

// 32 x 16 (452 bytes)
const gif = '';

// 250 x 167
const jpg = '';

const bmp = '';
const tiff = '';

const webpVP8 = '';
const webpVP8L = '';
const webpVP8X = '';

const createFileByType = (type) => {
	if (type === 'png')
	{
		const blob = createBlobFromDataUri(png);

		return new File([blob], 'image.png', { type: 'image/png' });
	}
	else if (type === 'png_fried')
	{
		const blob = createBlobFromDataUri(pngFried);

		return new File([blob], 'image_fried.png', { type: 'image/png' });
	}
	else if (type === 'gif')
	{
		const blob = createBlobFromDataUri(gif);

		return new File([blob], 'image.gif', { type: 'image/gif' });
	}
	else if (type === 'bmp')
	{
		const blob = createBlobFromDataUri(bmp);

		return new File([blob], 'image.bmp', { type: 'image/bmp' });
	}
	else if (type === 'jpg')
	{
		const blob = createBlobFromDataUri(jpg);

		return new File([blob], 'birds.jpg', { type: 'image/jpg' });
	}
	else if (type === 'webp')
	{
		const blob = createBlobFromDataUri(webpVP8L);

		return new File([blob], 'image.webp', { type: 'image/webp' });
	}
	else if (type === 'unsupported-image')
	{
		const blob = createBlobFromDataUri(tiff);

		return new File([blob], 'image.jpeg', { type: 'image/jpeg' });
	}
	else if (type === 'tiff' || type === 'tif')
	{
		const blob = createBlobFromDataUri(tiff);

		return new File([blob], 'image.tiff', { type: 'image/tiff' });
	}
	else if (['webpVP8', 'webpVP8L', 'webpVP8X'].includes(type))
	{
		const variable = eval(type);
		const blob = createBlobFromDataUri(variable);

		return new File([blob], 'image.webp', { type: 'image/webp' });
	}
	else if (type === 'csv')
	{
		return new File(
			[
				'John,Doe,120 jefferson st.,Riverside, NJ, 08075\n' +
				'Jack,McGinnis,220 hobo Av.,Phila, PA,09119'
			],
			'addresses.csv',
			{ type: 'text/csv' }
		);
	}
	else if (type === 'json')
	{
		return new File(
			[
				'{ "status": "success", "errors": null, data: 123 }'
			],
			'response.json',
			{ type: 'application/json' }
		);
	}
	else if (type === 'html')
	{
		return new File(['<html><body><b>Hello</b></body></html>'], 'index.html', { type: 'text/html' });
	}
	else if (type === 'css')
	{
		return new File(['body { color: red }'], 'styles.css', { type: 'text/css' });
	}
	else if (type === 'text')
	{
		return new File(['0123456789'.repeat(100)], 'text.txt', { type: 'text/plain' });
	}
	else
	{
		return new File(['123'], 'unknown.file', { type: 'application/octet-stream' });
	}
};

export default createFileByType;
